<template>
  <div class="waiting-info">
    <div class="list-item-setting" v-if="!optionsInfo.ListLocaleSys">
      <div class="title-info">
        <el-divider content-position="left">列表区域设置</el-divider>
      </div>
      <el-form-item label="视图模式">
        <el-select
          v-model="optionsInfo['viewMode']"
          placeholder="请选择"
        >
          <el-option
            v-for="item in viewModeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="展示行数">
        <el-input-number
          :min="3"
          :max="4"
          v-model="optionsInfo['showRowNums']"
          class="hide-spin-button"
          size="small"
        />
      </el-form-item>
      <el-form-item label="切屏时间(s)" class="switching-screen">
        <el-input-number
          :min="10"
          :step="1"
          size="small"
          class="hide-spin-button"
          v-model="optionsInfo['switchTime']"
        />
      </el-form-item>
    </div>
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">诊室设置</el-divider>
      </div>
      <div class="content">
        <roomNameKeyEditor
          businessType="special"
          :designer="designer"
          :selected-widget="selectedWidget"
          :option-model="optionModel"
        />
      </div>
    </div>


    <!--等待就诊滚动设置-->
    <div class="wait-visit-setting">
      <div class="title-info">
        <el-divider content-position="left">候诊区域</el-divider>
      </div>
      <el-form-item label="开启滚动">
        <el-switch v-model="optionsInfo['waitArea']['scroll']"/>
      </el-form-item>
      <el-form-item label="滚动速度">
        <el-input-number
          :min="1"
          :max="5"
          size="small"
          class="hide-spin-button"
          :disabled="!(optionsInfo['waitArea']['scroll'])"
          v-model="optionsInfo['waitArea']['step']"
        />
      </el-form-item>
      <el-form-item label="候诊类型设置" class="wait-patient-set">
        <el-radio-group
          v-model="optionsInfo.waitPatientType"
        >
          <el-radio
            :label="item.value"
            v-for="item in waitPatientTypeOptions"
            :key="item.value"
          >
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="候诊的人数">
        <el-input-number
          v-model="optionsInfo.waitPatientNumber"
          :min="14"
          :max="99"
          size="small"
          class="hide-spin-button"
        />
      </el-form-item>
    </div>

    <!--等待就诊滚动设置-->
    <div class="wait-visit-setting">
      <div class="title-info">
        <el-divider content-position="left">过号区域</el-divider>
      </div>
      <el-form-item label="开启滚动">
        <el-switch v-model="optionsInfo['passArea']['scroll']"/>
      </el-form-item>
      <el-form-item label="滚动速度">
        <el-input-number
          :min="1"
          :max="5"
          size="small"
          class="hide-spin-button"
          :disabled="!(optionsInfo['passArea']['scroll'])"
          v-model="optionsInfo['passArea']['step']"
        />
      </el-form-item>
    </div>
    <div class="list-item-setting">
      <el-divider content-position="left">呼叫患者弹层显示</el-divider>
      <el-form-item label="设置显示" class="wait-patient-set">
        <el-radio-group
          v-model="optionsInfo.checkList"
        >
          <el-radio
            :label="item.value"
            v-for="item in callPatientOptions"
            :key="item.value"
          >
            <template>
              {{ item.label }}
              <el-tooltip
                class="item"
                effect="dark"
                placement="bottom"
                content="当是叫号器登陆的时候，该属性生效"
                v-if="item.value==4"
              >
                <i class="el-icon-question"></i>
              </el-tooltip>
            </template>
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="显示内容" class="column-area" v-if="optionsInfo.checkList===5">
        <el-input class="hide-spin-button" v-model="optionsInfo.layerInfo.current.content"/>
      </el-form-item>
      <el-divider content-position="left">弹层顶部设置</el-divider>
      <el-form-item label="背景色" class="column-area">
        <el-color-picker
          size="small"
          show-alpha
          :predefine="predefineColors"
          v-model="optionsInfo['layerInfo']['current'].backgroundColor"/>
      </el-form-item>
      <el-form-item label="字体颜色" class="column-area">
        <el-color-picker
          size="small"
          show-alpha
          :predefine="predefineColors"
          v-model="optionsInfo['layerInfo']['current'].color"/>
      </el-form-item>

      <el-form-item label="字体大小" class="column-area">
        <el-input-number
          :min="14"
          size="small"
          class="hide-spin-button"
          v-model="optionsInfo['layerInfo']['current'].fontSize"
        />
      </el-form-item>
      <el-divider content-position="left">患者区域设置</el-divider>
      <el-form-item label="背景色" class="column-area">
        <el-color-picker
          size="small"
          show-alpha
          :predefine="predefineColors"
          v-model="optionsInfo['layerInfo']['current'].patientNumberBackground"/>
      </el-form-item>
      <el-form-item label="顶部字体颜色" class="column-area">
        <el-color-picker
          size="small"
          show-alpha
          :predefine="predefineColors"
          v-model="optionsInfo['layerInfo']['current'].patientColor"/>
      </el-form-item>

      <el-form-item label="顶部字体大小" class="column-area">
        <el-input-number
          :min="14"
          size="small"
          class="hide-spin-button"
          v-model="optionsInfo['layerInfo']['current'].patientFontSize"
        />
      </el-form-item>
    </div>
  </div>
</template>

<script>
import Draggable from "vuedraggable"
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import * as types from "@c/public/form-designer/devType/datas-types";
import roomNameKeyEditor from "@detailsEdit/scene-edit/basicInfo/roomNameKey-editor.vue";
import deptNameKeyEditor from "@detailsEdit/scene-edit/basicInfo/deptNameKey-editor.vue";

export default {
  name: "waitBloodConfig-editor",

  componentName: "waitBloodConfig-editor",

  components: {
    Draggable,
    deptNameKeyEditor,
    roomNameKeyEditor,
  },

  mixins: [],

  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      constantDic: constantDic,
      predefineColors: types['predefineColors'],
      waitPatientTypeOptions: types['waitPatientTypeOptions'],
      optionsInfo: {},
      viewModeOptions: [
        {
          value: 1,
          label: "采血视图",
        },
        {
          value: 2,
          label: "输液视图",
        }
      ],
      callPatientOptions: [
        {
          value: 1,
          label: '科室'
        },
        {
          value: 2,
          label: '号别'
        },
        {
          value: 3,
          label: '诊室'
        },
        {
          value: 5,
          label: '自定义'
        }
      ],
    }
  },

  computed: {
    // 判断字段是否存在
    fieldHas() {
      return function (field) {
        return Reflect.has(this.optionsInfo, field)
      }
    },

    isDisabled() {
      return function (val) {
        // let arr = ['deptName', 'treatmentRoomName', 'workerName'];
        let arr = Array();
        return arr.includes(val);
      }
    },

    registerObjNameOptions() {
      return this.$store.getters['templateDetails/getRegisterObjNameOptions']
    }
  },

  methods: {
    // 更改合并项
    handleMergeCol(event, key) {
      console.log(this.optionsInfo['mergeColInfo'][key])
    },


    // 拖动结束
    handleDragEnd() {
    },

    handleChangeWidth(event, key) {
      console.log(event)
      console.log(key)
    },

    handleCheckboxClick(event) {
      // 检查点击事件的目标是否为label元素
      if (event.target.tagName.toLowerCase() === 'label') {
        // 阻止事件冒泡，这样就不会触发el-checkbox-group的点击事件处理函数
        event.stopPropagation();
      }
    }

  },

  watch: {
    // 组件的所有信息
    optionModel: {
      handler: function (val) {
        this.optionsInfo = (val[val.config]);
      },
      deep: true,
      immediate: true
    }
  }

}
</script>

<style lang="scss" scoped>
.switching-screen {
  :deep(.el-input-number__decrease) {
    margin-top: 1px;
  }

  :deep(.el-input-number__increase) {
    margin-top: 1px;
  }
}

.call-patient-set {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    @include fontWeight();
    width: 100% !important;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;

    .el-checkbox-group {
      display: flex;
      flex-direction: column;
    }

    .el-select {
      width: 100%;
    }
  }
}

.tooltip-area {
  :deep(.el-form-item__content) {
    .wrap {
      display: flex;
      align-items: center;
      align-self: center;

      .right {
        .el-button {
          padding: 9px 8px;
          border: none;
          font-size: 18PX;
          color: #E6A23C;

          &:hover {
            background: transparent !important;
          }
        }
      }
    ;
    }

  }
}

.col-info {
  :deep(.el-form-item__content) {
    margin-left: 1px !important;

    .title {
      width: 100%;
    }

    .el-checkbox__label {
      width: auto;
    }


    .el-icon-thumb {
      position: relative;
      top: 8px;
      padding-left: 10px;
      font-size: 18px;
      text-align: center;
    }

    .el-checkbox {
      width: calc(100% - 32px);
    }
  }
}

//号别简称
.register-info {
  :deep(.el-form-item__content) {
    margin-left: 1px !important;

    .title {
      width: 100%;
    }

    .el-radio-group {
      .el-radio {
        width: 100%;
        padding: 8px 0;
      }
    }
  }
}

.row-option {
  :deep(.el-checkbox) {
    display: flex;
    flex-direction: row;

    .el-checkbox__input {
      display: flex;
      align-self: flex-start;
      align-items: flex-start;
    }

    .el-checkbox__label {
      display: flex;
      flex-direction: row;

      .setting-info {
        display: flex;
        flex-direction: column;

        .el-input {
          width: 100%;
          margin-bottom: 20px;

          input[type="number"] {
            line-height: 1px !important;
          }
        }

        .el-input-number {
          width: 100%;
        }

        .el-input__inner {
          padding-right: 0 !important;
        }
      }
    }
  }
}

.column-area {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
    margin-bottom: 10px;
  }

  :deep(.el-form-item__content) {
    width: 100%;
    margin-left: 0 !important;

    .el-radio-group {
      width: 100%;
      display: flex;
      flex-direction: column;

      .el-radio {
        margin-bottom: 10px;
      }
    }
  }

}

.wait-patient-set {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;;

    .el-radio-group {
      display: flex;
      flex-direction: column;

      .el-radio {
        padding: 10px 0;
      }
    }
  }

}
</style>
